package com.github.ghsea.sso.client.security.permission;

import javax.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * @author guhai
 */
@Component
public class UserManagerDelegate implements UserManager {

    @Resource(name = "UserManagerHttpImpl")
    private UserManager userManager;

    private UserManager customizeUserManager;

    @Override
    public User queryByMail(String mail) {
        if (customizeUserManager != null) {
            return customizeUserManager.queryByMail(mail);
        }

        return userManager.queryByMail(mail);
    }

    public UserManagerDelegate setCustomizeUserManager(UserManager customizeUserManager) {
        this.customizeUserManager = customizeUserManager;
        return this;
    }
}
